#include<iostream>
#include<cmath>
using namespace std;
const int N = 1000001;
int w[N], v[N];
int ans = 0;
void dfs(int dep, int sumw, int sumv, int n)
{
	if (dep == n + 1)
	{
		ans = max(ans, sumw);
		return;
	}
	dfs(dep + 1, sumw + w[dep], sumv + v[dep], n);
	dfs(dep + 1, sumw, sumv, n);
}
int main()
{
	int n = 0, p = 0;
	cin >> n >> p;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> v[i];
	}
	dfs(0, 0, 0, n);
	int res = pow(p, ans) % 998244353;
	cout << res;
	return 0;
}